home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / rexx / totape.mrbk < prev    next >
Text File  |  1992-10-11  |  3KB  |  143 lines

  1. /* ToTape.mrbk
  2.  *
  3.  * This ARexx program implements a generalized tape backup scheme which
  4.  * assumes that a given partition is backed up to alternating media
  5.  * depending upon which "cycle" is being performed. (A and B). The user
  6.  * is prompted for the cycle designation (A or B) and the rest is automatic.
  7.  *
  8.  * This script requires a single argument comprised of two values
  9.  * separated by a comma:
  10.  *
  11.  *      ToTape "<homepath>,<backpath>"
  12.  *
  13.  * where <homepath> is the name of the partition being backed up and
  14.  * backpath is the tape device name. Thus, you could define an entry
  15.  * in your MRBackup Macros menu such as:
  16.  *
  17.  *      MRBackup:Arexx_Scripts/ToTape DH0:,MRTape:
  18.  *      (Only "ToTape DH0:,MRTape:" will show in the menu.)
  19.  *
  20.  * MRBackup will then perform a fully automated backup, using the
  21.  * cycle name (A or B) as a suffix in constructing the save-set,catalog,
  22.  * listing and log file names.
  23.  */
  24.  
  25. signal on ERROR
  26. signal on BREAK_C
  27.  
  28. options results
  29. /* trace results */
  30.  
  31. if ~(Show('P', 'MRBackup_#1')) then do
  32.     address command 'run "MRBackup:MRBackup"'
  33.     address command 'WaitForPort "MRBackup_#1"'
  34. end
  35.  
  36. address "MRBackup_#1"
  37. poptofront
  38.  
  39. if arg() ~= 1 then do
  40. usage:
  41.     say "arg() = " arg()
  42.     'notealert "usage: ToTape <homepath>,<backpath>"'
  43.     exit 
  44. end
  45.  
  46. /* Break up the argument string. The "." is a placeholder which assures
  47.  * that all arguments are tokenized (pg. 79).
  48.  */
  49. parse arg homePath ',' backPath .
  50. say "homePath = " || homePath;
  51. say "backPath = " || backPath;
  52. 'getchoice "Which backup cycle?" "A" "B" "Cancel"'
  53. cycle = result
  54.  
  55. if cycle = "Cancel" then do
  56.     'notealert "This backup has been canceled."'
  57.     exit
  58. end
  59.  
  60. colonPos = pos(':', homePath)
  61. if colonPos < 2 then do
  62.     'notealert "You must specify a device name for the home path!"'
  63.     exit
  64. end
  65.  
  66. prefix = substr(homePath,1,colonPos - 1) || Backup || cycle
  67. say "Prefix = " || prefix
  68.  
  69. 'setfilemode "Replace"'
  70.  
  71. 'setbackupmode "SCSI Tape"'
  72.  
  73. 'setcomment "Full partition backup."'
  74.  
  75. 'setcompression "None"'
  76. 'testarcbits "NO"'
  77. 'setarcbits "NO"'
  78. 'keepemptydirs "YES"'
  79. setprefix prefix;
  80. 'setvoice "YES"'
  81.  
  82. 'sethomepath' homePath
  83. if rc ~= 0 then do
  84.     say "sethomepath failed - " homePath
  85.     exit 1
  86. end
  87.  
  88. 'setbackpath' backPath
  89. if rc ~= 0 then do
  90.     say "I failed to set the backup path: " backPath
  91.     exit 1
  92. end
  93.  
  94. catalogFile = "MRBackup:Catalogs/" || prefix || ".cat"
  95. say "Catalog = " catalogFile
  96.  
  97. 'setcatalogname' catalogFile
  98. if rc ~= 0 then do
  99.     say "setcatalogname failed - " catalogFile
  100.     exit
  101. end
  102.  
  103. logFile = "MRBackup:Lists_and_Logs/" || prefix || ".log"
  104. setlogpath logFile
  105.  
  106. listFile = "MRBackup:Lists_and_Logs/" || prefix || ".list"
  107. setlistpath listFile
  108.  
  109. /* setbufsize 60 */
  110.  
  111. 'setbfilterpath " "'
  112. 'setcfilterpath " "'
  113. 'setdfilterpath " "'
  114.  
  115. takecontrol
  116. backup
  117. save_rc = rc
  118. releasecontrol
  119. if save_rc ~= 0 then do
  120.     say "Backup failed; error code: " || save_rc
  121.     exit 1
  122. end
  123.  
  124. exit 0
  125.  
  126.  
  127. /*------------------------------------------------------------------*/
  128.  
  129. break_c:
  130.  
  131. say "*** Control-C recieved.  Stopped by user. ***"
  132. exit 5
  133.  
  134. /*------------------------------------------------------------------*/
  135.  
  136. error:
  137.  
  138. say "Error"
  139. exit 6
  140.  
  141. /*------------------------------------------------------------------*/
  142.  
  143.